package com.medistat.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="UserInfo")
public class User extends StandardPersistentObject {
	
	@Id @GeneratedValue(generator="ID_GENERATOR_FOR_USER")
	@GenericGenerator(name="ID_GENERATOR_FOR_USER", strategy = "increment")
	private Long id;
	
	//parent - back reference
	@ManyToOne(targetEntity=Department.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="DepartmentID", referencedColumnName="ID") })	
	@Basic(fetch=FetchType.LAZY)
	private Department department;
	
	@Column(name="nameForUser")
	private String username;
	
	@Column(name="passwordForUser")
	private String password;
	
	@Override
	public Long getId() {
		return id;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String nameForUser) {
		this.username = nameForUser;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String pass) {
		this.password = pass;
	}
}
